<div id="profileDetail" align="center">
  <div class="well" style="width:55%;">
    <%= form_tag client_update_profile_path, method: "post" do %>
      <table cellpadding="10" style="margin-bottom: 10px;">
        <tr>
          <td align="right"><b><%= t("client.name") %>(*)</b></td>
          <td>
            <%= text_field_tag(
                  :name,
                  @user.name,
                  type: :text,
                  required: :required,
                  class: :text) %></td>
        </tr>
        <tr>
          <td align="right"><b><%= t("client.email") %></b></td>
          <td>
            <%= text_field_tag(
                  :email,
                  @user.email,
                  type: :email,
                  class: :text) %></td>
        </tr>
        <tr>
          <td align="right"><b><%= t("client.address") %>(*)</b></td>
          <td>
            <%= render(
                  partial: 'client/address',
                  locals: {
                    address: @user.address,
                    shipCostCallback: nil }) %>
          </td>
        </tr>
        <tr>
          <td align="right"><b><%= t("client.phone") %>(*)</b></td>
          <td>
            <%= text_field_tag(
                  :phone,
                  @user.phone,
                  type: :tel,
                  required: :required,
                  class: :text) %></td>
        </tr>
      </table>
      <%= submit_tag t("client.update"), class: "blueButton" %>
      <button id="logoutButton" class="redButton" style="margin-left:20px;"><%= t("client.logout") %></button>
    <% end %>
  </div>

  <br/>
  <br/>

  <div style="width:60%;" align="left">
    <h3><%= t 'client.order.list' %></h3>
    <hr/>
    <div style="float:left;margin-top:20px;margin-bottom:20px;">
      <%= form_tag client_profile_path, method: :get do %>
        <%= text_field_tag(
              :order_keyword,
              @order_keyword,
              style: 'width:350px;height:30px;padding:2px;',
              placeholder: t('client.order.search_hint')) %>
        <%= link_to '[?]', "#{client_info_path}#search_hint", target: '_blank' %>
      <% end %>
    </div>
    <% if @orders && @orders.length > 0 %>
      <div style="clear:both;">
        <table class="client_data_table clickable_table" style="width:100%">
          <tr>
            <th><%= t "client.code" %></th>
            <th><%= t "client.desc" %></th>
            <th><%= t "client.total" %></th>
            <th><%= t "client.status" %></th>
            <th><%= t "client.update" %></th>
          </tr>
          <% @orders.each do |o| %>
            <tr onclick="location.href='<%= client_order_path(o.code) %>'">
              <td><%= o.code %></td>
              <td><%= o.desc %></td>
              <td><%= number_to_currency o.sum, unit: "", precision: 0 %></td>
              <td>
                <%= o.step_as_text %>
                <%= link_to '[?]', "#{client_info_path}#steps_desc", target: '_blank' %>
              </td>
              <td>
                <%= render partial: "common/datetime", locals: { val: o.updated_at } %>
              </td>
            </tr>
          <% end %>
        </table>
      </div>
      <div style='float:right'>
        <%= paginate @orders %>
      </div>
    <% else %>
      <div style="clear:both;">
        <h2><%= t 'client.no_order' %></h2>
      </div>
    <% end %>
  </div>
</div>

<script type="text/javascript">
  profile("<%= client_logout_path %>");
</script>